package com.wyz.socket.core.base.packet;

import java.io.OutputStream;

public abstract class AbstractReceivePacket<Entity, Stream extends OutputStream> extends Packet<Stream> {

    protected Entity entity;

    public AbstractReceivePacket(int length) {
        this.length = length;
    }

    public Entity entity() {
        return entity;
    }


    protected abstract Entity build(Stream stream);

    @Override
    protected void onCloseStream(Stream stream) {
        super.onCloseStream(stream);
        entity = build(stream);
    }
}
